export default {
    success(title, options = { duration: 1500 }) {
        return new Promise((resolve, reject) => {
            wx.showToast({
                ...options,
                title,
                icon: 'success',
                success(res) {
                    setTimeout(() => {
                        resolve(res);
                    }, options.duration);
                },
                fail(res) {
                    reject(res);
                }
            });
        });
    },
    fail(title, options = {duration: 1500}) {
        return new Promise((resolve, reject) => {
            wx.showToast({
                ...options,
                title,
                icon: 'error',
                success(res) {
                    resolve(res);
                },
                fail(res) {
                    reject(res);
                }
            });
        });
    },
    message(title, options = {duration: 1500}) {
        return new Promise((resolve, reject) => {
            wx.showToast({
                ...options,
                title,
                icon: 'none',
                success(res) {
                    setTimeout(() => {
                        resolve(res);
                    }, options.duration);
                },
                fail(res) {
                    reject(res);
                }
            });
        });
    }
};
